<?php
// +----------------------------------------------------------------------
// | 零云 [ 简单 高效 卓越 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016 http://www.lingyun.net All rights reserved.
// +----------------------------------------------------------------------
// | Author: jry <598821125@qq.com>
// +----------------------------------------------------------------------
namespace Home\Controller;

use Think\Page;

/**
 * 导航控制器
 * @author jry <598821125@qq.com>
 */
class wxpayController extends HomeController
{
    /**
     * 默认方法
     * @author jry <598821125@qq.com>
     */
    public function index()
    {
        die('hello world');
    }

    /**
     * 单页类型
     * @author jry <598821125@qq.com>
     */
    public function Notify()
    {
        wxnofity();
    }

    public function pay($payid)
    {
        $order_object = D('Admin/Inviteorder');
        
        $invite_object   = D('Admin/Invitation');
        $payid = substr($payid,0,32);
        $data = $order_object->where('payorderid="'.$payid.'"')->find();
        $info = $invite_object->where('id='.$data['inviteid'])->find();
        $data['price_data'] = unserialize($data['price_data']);
        foreach ($data['price_data'] as $val) {
            if ($val==$info['price']) {
                $data['price_split'][$val]['name'] = '普通票';
            }elseif ($val==$info['s1_price']) {
                $data['price_split'][$val]['name'] = $info['s1_name'];
            }elseif ($val==$info['s2_price']) {
                $data['price_split'][$val]['name'] = $info['s2_name'];
            }elseif ($val==$info['s3_price']) {
                $data['price_split'][$val]['name'] = $info['s3_name'];
            }elseif ($val==$info['s4_price']) {
                $data['price_split'][$val]['name'] = $info['s4_name'];
            }
            $data['price_split'][$val]['num'] ++;
            $data['price_split'][$val]['price'] = $val; 
        }
        $this->assign('info',$info);
        $this->assign('order',$data);
        $this->assign('params',wxpay($info,$data));
        $this->display('pay');
        //wxpay($payid);
    }

    public function fpay() {
        $inviteid = $_POST['inviteid'];
        $mobile = $_POST['mobile'];
        $orderid = $_POST['id'];
        send_sms($mobile,2,$orderid,0);
        $this->redirect('Nav/invitation',array('id'=>$inviteid));
        //$this->success('支付成功，感谢您的参与',U('Nav/invitation',array('id'=>$inviteid)));
    }

    

    

    
}
